<style>
    /* 抵扣券 */
  .couponBtn{font-size:0.22rem;color:#c21717;margin-left:0.2rem;font-size:0.26rem;}
  .orderPrice{
      font-size:0.26rem;
      color:#999999;
      text-decoration: line-through;
  }
  .Dcoupon-container{
      width:100%;
      height:100%;
      position:fixed;
      left:0;
      top:0;right:0;
      bottom:0;
      z-index: 99;
      display: none;
  }
  .Dcoupon-bg{width:100%;height:100%;background-color:rgba(0,0,0,0.5);position: absolute;}
  .Dcoupon-wrap{
      width:5.44rem;
      height:5.94rem;
      background:url('__PUBLIC__/images/public/img_bj.png') 0% 0% /100% 100% no-repeat;
      position: absolute;
      left:50%;
      margin-left:-2.72rem;
      z-index: 1;
      top:15%;
      text-align: center;
  }
  .Dcoupon-title{font-size:0.59rem;color:#ffffff;margin:0.4rem 0 0.2rem;}
  .Dcoupon-sub{font-size:0.32rem;color:#ffffff;}
  .Dcoupon-input{
      width:4.42rem;
      height:0.96rem;
      border:none;
      border-radius: 0.1rem;
      margin-top:0.36rem;
      padding:0 0.2rem;
      box-sizing:border-box;
      font-sizE:0.32rem;
  }
  .Dcoupon-use{
      width:3.52rem;
      height:0.84rem;
      line-height:0.84rem;
      text-align: center;
      background: linear-gradient(left,#F33300,#F95900);
      background: -webkit-linear-gradient(left,#F33300,#F95900);
      border-radius: 0.7rem;
      font-size:0.32rem;
      color:#ffffff;
      position:absolute;
      bottom:0.48rem;
      left:50%;
      margin-left:-1.76rem;
  }
  .Dcoupon-close{
      width:0.62rem;
      height:0.62rem;
      background:url('__PUBLIC__/images/public/close_.png') 0% 0% /100% 100% no-repeat;
      position:absolute;
      bottom:-1rem;
      left:50%;
      margin-left:-0.31rem;
  }
  .Dcoupon-sucess-wrap{
      width:5.22rem;
      height:5rem; 
      background-color:#ffffff;
      border-radius:0.7rem;
      position: absolute;
      left:50%;
      margin-left:-2.61rem;
      top:15%;
      text-align: center;
      display: none;
  }
  .Dcoupon-sucess-title{
      width:3.26rem;
      height:0.8rem;
      font-size:0.44rem;
      color:#ffffff;
      text-align: center;
      line-height:0.8rem;
      background: url('__PUBLIC__/images/public/img_bt.png') 0% 0% /100% 100% no-repeat;
      position:absolute;
      left:50%;
      margin-left:-1.63rem;
      top:-0.4rem;
  }
  .Dcoupon-sucess-img{width:2.2rem;height:1.68rem;margin-top:0.7rem;}
  .Dcoupon-sucess-r{font-size:0.22rem;color:#f64c3e;margin:0.15rem 0;}
  .Dcoupon-sucess-p{font-size:0.2rem;color:#605f5f;}
  .Dcoupon-sucess-ok{
      width:2.82rem;
      height:0.84rem;
      line-height:0.84rem;
      text-align: center;
      background: linear-gradient(left,#F33300,#F95900);
      background: -webkit-linear-gradient(left,#F33300,#F95900);
      border-radius: 0.7rem;
      font-size:0.32rem;
      color:#ffffff;
      margin:0.44rem auto 0;
  }
</style>
<!-- 抵用券弹窗 -->
<div class="Dcoupon-container">
    <div class="Dcoupon-bg"></div>
    <div class="Dcoupon-wrap">
        <h3 class="Dcoupon-title">输入抵用券</h3>
        <p class="Dcoupon-sub">运程测算更优惠哦！</p>
        <input type="text" class="Dcoupon-input" placeholder="请输入抵用券码">
        <div class="Dcoupon-use">我要优惠</div>
        <div class="Dcoupon-close"></div>
    </div>
    <div class="Dcoupon-sucess-wrap">
        <h3 class="Dcoupon-sucess-title">恭喜您</h3>
        <img src="__PUBLIC__/images/public/img_gxn.png" class="Dcoupon-sucess-img" alt="">
        <p class="Dcoupon-sucess-r">恭喜！您已获得超值优惠</p>
        <p class="Dcoupon-sucess-p">温馨提示：优惠仅限本次，千万不要错过哦！</p>
        <div class="Dcoupon-sucess-ok">好的</div>
        <div class="Dcoupon-close"></div>
    </div>
</div>
<script>
    var server = "<!--{$Think.cookie.orderidnum}-->";
    var discount = "<!--{$Think.cookie.discountprice}-->"; // 已优惠价格
    var channel = "<!--{$Think.cookie.channel}-->" // 渠道
    var price = "<!--{$Think.cookie.price}-->" // 价格

    $(function () {
        console.log(server)
        if (channel == 'qudao227'||channel=='qudao100') {
            if (server == 'Zwds' || server == 'Lath') {
                $('.orderMoney').html(
                    `<span style="font-size:0.28rem;color:#666666;">优惠价：</span><strong style="font-size:0.48rem;color:#d12f36;">￥${price}</strong><span class="couponBtn">本次优惠</span>`
                )
            } else if (server == 'Bbqm' || server == 'Pfc') {
                $('.orderMoney').html(
                    `<strong style="font-size:0.32rem;color:#d12f36;">￥${price}</strong><span class="couponBtn">本次优惠</span>`
                )
            } else {
                $('.orderMoney').html(
                    `<span style="font-size:0.26rem;color:#333333;">只需${price}元</span><span class="couponBtn">本次优惠</span>`
                )
            }

            console.log(discount+'data');

            if (discount != 0) {
                if (server == 'Zwds' || server == 'Lath') {
                    $('.orderMoney').html(
                        `<span style="font-size:0.28rem;color:#333333;font-weight:bold;">现价</span><span style="font-size:0.48rem;color:#f73232;font-weight:bold;">${price}元</span><span style="font-size:0.18rem;color:#333333;">(已抵扣${discount}元)</span>`
                    )
                } else {
                    $('.orderMoney').html(
                        `<span style="font-size:0.26rem;color:#333333;font-weight:bold;">现价</span><span style="font-size:0.33rem;color:#f73232;font-weight:bold;">${price}元</span><span style="font-size:0.18rem;color:#333333;">(已抵扣${discount}元)</span>`
                    )
                    exit;
                }
            }
            $('.couponBtn').click(function () {
                $('.Dcoupon-container').fadeIn(300);
            })
            $('.Dcoupon-close').click(function () {
                $('.Dcoupon-container').fadeOut(300);
            })
            $('.Dcoupon-sucess-ok').click(function () {
                $('.Dcoupon-container').fadeOut(300);
            })
            $('.Dcoupon-use').click(function () {
                let couponVal = $('.Dcoupon-input').val();
                $.post("<!--{:U('Index/couponSelect','',false)}-->", {
                    code: couponVal
                }, function (response) {
                    let data = JSON.parse(response)
                    if (data.code === 1) {
                        $('.Dcoupon-wrap').fadeOut();
                        $('.Dcoupon-sucess-wrap').fadeIn();
                        $('.public_pp_price strong').text(`￥${data.price}元`)
                        if (server == 'Zwds' || server == 'Lath') {
                            $('.orderMoney').html(
                                `<span style="font-size:0.28rem;color:#333333;font-weight:bold;">现价</span><span style="font-size:0.48rem;color:#f73232;font-weight:bold;">${data.price}元</span><span style="font-size:0.18rem;color:#333333;">(已抵扣${data.discount}元)</span>`
                            )
                        } else {
                            $('.orderMoney').html(
                                `<span style="font-size:0.26rem;color:#333333;font-weight:bold;">现价</span><span style="font-size:0.33rem;color:#f73232;font-weight:bold;">${data.price}元</span><span style="font-size:0.18rem;color:#333333;">(已抵扣${data.discount}元)</span>`
                            )
                        }
                    } else {
                        layer.msg("抵用券无效，请重新输入");
                        $('.Dcoupon-input').val('')
                    }
                    console.log(data)
                })
            })
        }
    })
</script>
<script>
    // 半价优惠
    const priceBJ = "<!--{$Think.cookie.discountQczh}-->"
    $(function () {
        if (parseInt(priceBJ) === 1) {
            if (server == 'Bbqm' || server == 'Pfc') {
                $('.orderMoney').html(
                    `<span style="color:#F95900;font-size:0.24rem;">(已享受新用户半价优惠)</span><strong style="font-size:0.32rem;color:#d12f36;">￥${price}</strong>`
                )
            } else {
                $('.orderMoney').html(
                    `<span class="orderPrice">原价:${price * 2}元</span><span style="font-size:0.26rem;color:#333333;margin-left:0.2rem">只需${price}元</span></br><span
    style="color:#F95900;font-size:0.24rem;">本次测算已使用新用户优惠券，<br/>可享半价优惠</span>`
                )
            }
        }
    })
</script>
<include file="Public/payment" />